package com.inlycat.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.inlycat.entity.Barrage;
import com.inlycat.entity.VideoAttr;
import com.inlycat.mapper.BarrageMapper;
import com.inlycat.mapper.VideoAttrMapper;
import com.inlycat.service.BarrageService;

/**
 * @author jarvan4dev@163.com
 * @since 2015年8月24日上午10:54:47
 * @category 
 **/
@Service("barrageService")
public class BarrageServiceImpl implements BarrageService {
	
	@Resource
	private BarrageMapper barrageMapper;
	
	@Resource
	private VideoAttrMapper videoAttrMapper;

	@Override
	public boolean add(Barrage barrage) {
		VideoAttr videoAttr = new VideoAttr();
		videoAttr.setVideoId(barrage.getVideoId());
		videoAttr.setBarrageCount(1);
		videoAttrMapper.updateSelectiveByVideoId(videoAttr);
		boolean result = barrageMapper.insert(barrage);
		return result;
	}

	@Override
	public List<Barrage> select(Barrage barrage) {
		List<Barrage> barrages = barrageMapper.select(barrage);
		return barrages;
	}

}
